<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>正文</title>
    <link rel="shortcut icon" href="./img/logo.jpg">
    <link rel="stylesheet" href="css/blog.css">
    <link rel="stylesheet" href="css/blog_content.css">
    <!-- 引入 editor.md 的依赖 -->
    <link rel="stylesheet" href="editor.md/css/editormd.min.css" />
    <script src="js/jquery-2.2.4.min.js"></script>
    <script src="editor.md/lib/marked.min.js"></script>
    <script src="editor.md/lib/prettify.min.js"></script>
    <script src="editor.md/editormd.js"></script>
</head>

<body>
    <!-- 导航栏 -->
    <div class="nav">
        <img src="./img/logo.jpg" alt="">
        <span class="title">博客系统</span>

        <!-- 用来占据中间位置 -->
        <span class="spacer"></span>
        <a th:if="${showDeleteButton}" th:href="${'blogDelete?blogId='+blog.blogId}">删除</a>
        <a href="blog_list.html">主页</a>
        <a href="blog_edit.html">创作</a>
        <a href="logout">注销</a>
    </div>

    <!-- 版心 -->
    <div class="container">
        <!-- 左侧个人信息 -->
        <div class="container-left">
            <!--个人信息卡片-->
            <div class="card">
                <!--头像-->
                <img src="./img/头像.jpg" class="avtar" alt="">
                <!--用户名-->
                <h3 th:text="${user.username}"></h3>
            </div>
        </div>
        <!--右侧正文内容-->
        <div class="container-right">
            <div class="blog-content">
                <!-- 博客标题 -->
                <h3 th:text="${blog.title}"></h3>
                <!-- 博客发布时间 -->
                <div class="date" th:text="${blog.postTime}"></div>
                <!-- 博客正文, 这个 div 里面就保存了 markdown 的原始内容 -->
                <div id="content" th:text="${blog.content}" style="background-color: transparent;"></div>
            </div>
        </div>
    </div>

    <script>
        function renderMD() {
            //markdown形式的正文页面
            let contentDiv = document.querySelector('#content');
            let markdown = contentDiv.innerHTML;
            contentDiv.innerHTML = '';
            editormd.markdownToHTML('content', {
                markdown: markdown
            });
        }
        renderMD();
    </script>
</body>

</html>